<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WISSC轮滑教培服务网-查询系统-查询系统</title>
    <#assign base=request.contextPath  />
    <link rel="icon" href="${base}/favicon.ico">
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <script src="${base}/frame/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script src="${base}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${base}/js/feng.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/css/hzw-city-picker.css">
    <script type="text/javascript" src="${base}/js/city-data.js"></script>
    <script type="text/javascript" src="${base}/js/hzw-city-picker.min.js"></script>
    <script type="text/javascript" src="${base}/js/city-zk.js"></script>
    <script type="text/javascript" src="${base}/js/province.js"></script>
</head>

<body>
<form class="layui-form" action="" style="margin: 10px">
    <div class="layui-form-item">
        <input type="hidden" id="id" value="${id}"/>

        <div class="layui-inline">
            <label class="layui-form-label"><a style="color:red">*</a>&nbsp;配置类型</label>
            <div class="layui-input-inline">
                <input name="type" id="type" disabled lay-verify="required" autocomplete="off" class="layui-input isNull"
                       type="text">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label"><a style="color:red">*</a>&nbsp;配置值</label>
            <div class="layui-input-inline">
                <textarea  name="configure" id="configure" lay-verify="required" autocomplete="off"
                           class="layui-input isNull" style="height: 86px;width: 268px;"></textarea>
            </div>
        </div>


    <div class="layui-form-item">
        <div class="layui-input-inline">
            <button class="layui-btn " lay-submit lay-filter="formDemo" type="button" onclick="onSubmit()"
                    id="aa" style="background-color: #0092EF;">立即提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary ">重置</button>
        </div>
    </div>
</form>

<script>


    layui.use('upload', function () {
        var $ = layui.jquery
                , upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '${base}/file/uploadFile'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //上传成功
                //alert(res.data);
                aa = res.data;
                return res.data;
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    })
</script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate', 'layer'], function () {
        var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

    });

</script>
<script>


    function onSubmit() {

        var jsonData = {};
        jsonData.configure = $("#configure").val();
        jsonData.id = $("#id").val();
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            type: "POST", //提交方式
            traditional: true,//这里设置为true,不然后台接收到的参数会带上[]，导致数据无法正常接收
            url: "${base}/configure/updateByIdConfigure",
            data: JSON.stringify(jsonData),
            success: function (data) {
                if(data.code == 0){
                    layer.msg("修改成功")
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },300)
                    var table = parent.layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/configure/select'//数据接口
                        , where: {} //设定异步数据接口的额外参数
                        //,height: 300
                    });
                }else{
                    layer.msg("修改失败")
                }
            }
        });

    }


</script>

</body>
</html>
